import { agentTools } from './env'

console.log(agentTools)

function on (target, type, callback, isOnce) {
  if (target.addEventListener) {
    target.addEventListener(type, function __fn (e) {
      isOnce && target.removeEventListener(type, __fn, false)
      callback.call(this, e)
    }, false)
  } else if (target.attachEvent) {
    target.attachEvent('on' + type, function __fn (e) {
      isOnce && target.detachEvent('on' + type, __fn)
      callback.call(this, e)
    })
  }
  return this
}

var WeexBonreeAgent = function (props) {
  // var that=this;
}

WeexBonreeAgent.prototype = {
  constructor: WeexBonreeAgent,
  errorDell: function (e) {

  },
  handleError: function () {
    on(agentTools.win, 'error', function (e) {
      // eslint-disable-next-line no-undef
      errorDell(e)
    })
    on(agentTools.win, 'unhandledrejection', function (e) {
      // eslint-disable-next-line no-undef
      errorDell(e)
    })
  }
}
